<?php

use App\Http\Controllers\Api\TestController;
use App\Http\Controllers\Api\UserController;
use App\Http\Controllers\Api\OrderController;

$api = app('Dingo\Api\Routing\Router');

$api->version('v1', [], function ($api) {

    // 用户相关
    $api->group(['prefix' => 'user'], function ($api) {
        // 注册
        $api->post('register', [UserController::class, 'register']);
        // 登录
        $api->get('login', [UserController::class, 'login']);
        // 退出登录
        $api->get('logout', [UserController::class, 'logout']);
        // 登录信息
        $api->get('me', [UserController::class, 'me'])->middleware('api.auth');
        // 用户信息
        $api->get('show', [UserController::class, 'show'])->middleware('api.auth');
    });
    // 订单相关
    $api->group(['prefix' => 'order', 'middleware' => ['refresh.token', 'api.auth']], function ($api) {
        // 提交订单
        $api->post('store', [OrderController::class, 'store']);
    });
    // 测试相关
    $api->group(['prefix' => 'test'], function ($api) {
        // 测试任务队列
        $api->any('testJob', [TestController::class, 'testJob']);
        // 测试资源数据列
        $api->any('collection', [TestController::class, 'collection']);
        // 生成二维码
        $api->any('createQRCode', [TestController::class, 'createQRCode']);
        // 合成海报图
        $api->any('createShareImage', [TestController::class, 'createShareImage']);
        // 测试Api
        $api->any('testApi', [TestController::class, 'testApi']);
    });
});
